package com.huang.a01_define;

/**
 * 目标：
 * 方法案例
 */
public class Demo4_Method {
    public static void main(String[] args) {
        System.out.println(sum(100));

        judge(21);
        judge(10);
    }
    public static int sum(int n){
        int sum = 0;
        for (int i = 1; i <= n ; i++) {
            sum += i;
        }
        return sum;
    }

    public static void judge(int num){
        if (num % 2 == 0) {
            System.out.println(num + "是偶数");
        } else {
            System.out.println(num + "是奇数");
        }
    }
}